
local rexvemengxiang = fk.CreateSkill {
  name = "rexvemengxiang",
  tags = { Skill.Wake },
}

Fk:loadTranslationTable{
  ["rexvemengxiang"] = "热血梦想",
  [":rexvemengxiang"] = "觉醒技，结束阶段开始时，若你已造成过5点伤害，你令所有梦之队势力玩家获得技能【燃英】，并令自身获得【焚火】",
}

rexvemengxiang:addEffect(fk.TurnEnd, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(rexvemengxiang.name) and player.phase == Player.Start and
      player:usedSkillTimes(rexvemengxiang.name, Player.HistoryGame) == 0
  end,
  can_wake = function(self, event, target, player, data)
   if target == player and player:hasSkill(rexvemengxiang.name) then
      local x = 0
      player.room.logic:getActualDamageEvents(1, function (e)
        local damage = e.data
        if damage.from == player then
          x = x + damage.damage
          return x >= player.hp
        end
        return false
      end)
      return x >= 5
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:handleAddLoseSkills(Player, "rexvefenhuo")
    for _, p in ipairs(room:getAlivePlayers()) do
      -- 为每个存活玩家添加 "n_fenliang" 技能
      -- 第三个参数 nil 表示不指定技能的额外参数，第四个参数 false 表示不是临时添加技能
      if p.kingdom == "dream" then
        -- 指示目标玩家指向额外目标
        room:handleAddLoseSkills(p, "ranyingliehuo")
     end
    end
  end,
})

return rexvemengxiang
